<?php

namespace app\api\controller\v1;

use app\common\controller\Api;
use app\common\logic\HandlerApi;
use app\common\utils\Utils;
use think\Db;

/**
 * 首页接口
 */
class Article extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];



    public function suggession() {
        $content = input('content/s', '');
        if (!$content) {
            $this->error('请填写意见内容');
        }
        $images = input('images/a', []);
        /*$saveImages = [];
        foreach ($images as $k => $v) {
            $img = Utils::base64_image_content($v);
            array_push($saveImages, $img);
        }*/



        $tel = input('tel/s', '');
        $res = Db::name('suggession')->insert([
            'user_id' => $this->auth->id,
            'content' => $content,
            'createtime' => time(),
            'tel' => $tel,
            'images' => Utils::implodeArr($images, ',')
        ]);

        if (!$res) {
            $this->error('提交失败');
        }

        $this->success('提交成功');
    }
}
